#include "orb.h"

#include <time.h>

Orb::~Orb()
{
	
}

Orb::Orb() :
	Sprite(Vector2f(), Vector2f(), "orangecube"),
	gdata( Gamedata::getInstance() )
{
	int width = gdata.getXmlInt("worldWidth"); 
	int height = gdata.getXmlInt("worldHeight");
	int orbWidth = gdata.getXmlInt("redorbWidth");
	int orbHeight = gdata.getXmlInt("redorbHeight");
	const int minSpeedX = gdata.getXmlInt("redorbsXspeedMin");
	const int maxSpeedX = gdata.getXmlInt("redorbsXspeedMax");
	const int minSpeedY = gdata.getXmlInt("redorbsYspeedMin");
	const int maxSpeedY = gdata.getXmlInt("redorbsYspeedMax");

	int x = rand()% (width-orbWidth) + orbWidth/2;
	int y = rand()% (height-orbWidth) + orbHeight/2;
	int sx = (rand() % (maxSpeedX-minSpeedX)) + minSpeedX;
	int sy = (rand() % (maxSpeedY-minSpeedY)) + minSpeedY;
	sx = x - sx*(1.0/30.0)*(rand()%2?1:-1);
	sy = y - sy*(1.0/30.0)*(rand()%2?1:-1);

	setPosition(Vector2f(x, y));
	//setVelocity(Vector2f(sx,sy));
}

void Orb::update()
{
	
}
